//
//  CustomerContractViewCell.m
//  EPBPro
//
//  Created by wucha on 2018/6/27.
//  Copyright © 2018年 fc. All rights reserved.
//

#import "CustomerContractViewCell.h"

@interface CustomerContractViewCell()
@property (nonatomic,strong) UILabel *nameLabel;
@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UILabel *cardNumLabel;
@property (nonatomic,strong) UILabel *numLabel;
@property (nonatomic,strong) UILabel *dateLabel;

@end

@implementation CustomerContractViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
        UIView *backView = [UIView new];
        backView.layer.cornerRadius = 10;
        backView.backgroundColor = DefaultTenantColor;
        [self.contentView addSubview:backView];
        backView.sd_layout.leftSpaceToView(self.contentView, 10).topSpaceToView(self.contentView, 5).rightSpaceToView(self.contentView, 10).bottomSpaceToView(self.contentView, 0);
        
        UILabel *nameLabel = [UILabel new];
        nameLabel.text = @"xxx";
        nameLabel.font = [UIFont systemFontOfSize:14];
        nameLabel.textColor = [UIColor whiteColor];
        [backView addSubview:nameLabel];
        nameLabel.sd_layout.leftSpaceToView(backView, 15).topSpaceToView(backView, 10).heightIs(14).rightSpaceToView(backView, 15);
        self.nameLabel = nameLabel;
        
        UILabel *titleLabel = [UILabel new];
        titleLabel.text = @"xxxxx";
        titleLabel.font = [UIFont systemFontOfSize:20];
        titleLabel.textColor = [UIColor whiteColor];
        [backView addSubview:titleLabel];
        titleLabel.sd_layout.leftSpaceToView(backView, 15).topSpaceToView(nameLabel, 15).heightIs(20).autoWidthRatio(0);
        [titleLabel setSingleLineAutoResizeWithMaxWidth:200];
        self.titleLabel = titleLabel;
        
        UILabel *numLabel = [UILabel new];
        numLabel.text = @"xxxxx";
        numLabel.font = [UIFont systemFontOfSize:12];
        numLabel.textColor = [UIColor whiteColor];
        [backView addSubview:numLabel];
        numLabel.sd_layout.leftSpaceToView(titleLabel, 30).topSpaceToView(nameLabel, 17).heightIs(20).rightSpaceToView(backView, 20);
        self.numLabel = numLabel;
        
        UILabel *cardNumLabel = [UILabel new];
        cardNumLabel.text = @"xxx";
        cardNumLabel.font = [UIFont systemFontOfSize:14];
        cardNumLabel.textColor = [UIColor whiteColor];
        [backView addSubview:cardNumLabel];
        cardNumLabel.sd_layout.leftSpaceToView(backView, 15).topSpaceToView(titleLabel, 10).heightIs(14).autoWidthRatio(0);
        [cardNumLabel setSingleLineAutoResizeWithMaxWidth:200];
        self.cardNumLabel = cardNumLabel;
        
        UILabel *dateLabel = [UILabel new];
        dateLabel.text = @"xxx";
        dateLabel.font = [UIFont systemFontOfSize:14];
        dateLabel.textColor = [UIColor whiteColor];
        [backView addSubview:dateLabel];
        dateLabel.sd_layout.leftSpaceToView(backView, 15).topSpaceToView(cardNumLabel, 10).heightIs(14).rightSpaceToView(backView, 15);
        self.dateLabel = dateLabel;
        
        UIImageView *arrowImageView = [UIImageView new];
        arrowImageView.contentMode = UIViewContentModeCenter;
        arrowImageView.image = [UIImage imageNamed:@"machine_arrow"];
        [backView addSubview:arrowImageView];
        arrowImageView.sd_layout.rightSpaceToView(backView, 10).topSpaceToView(backView, 10).bottomSpaceToView(backView, 10).widthIs(20);
    }
    return self;
}

-(void)setCustomerContractCell:(CustomerContractInfo*)customerContractInfo{
    self.nameLabel.text = [NSString stringWithFormat:@"合同编号:%@",customerContractInfo.id];
    self.titleLabel.text = customerContractInfo.contactor;
    self.cardNumLabel.text = [NSString stringWithFormat:@"联系方式:%@",customerContractInfo.contactPhone];
    self.dateLabel.text = [NSString stringWithFormat:@"%@到%@",[Utils dateConvert:customerContractInfo.startDate],[Utils dateConvert:customerContractInfo.endDate]];
    self.numLabel.text = [NSString stringWithFormat:@"数量:%@台",customerContractInfo.equipmentNum];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
